package demo.jdk8;

import java.lang.annotation.Repeatable;

import org.junit.Test;

public class AnnotationsTest {

	@interface Hints {
		Hint[] value();
	}

	@Repeatable(Hints.class)
	@interface Hint {
		String value();
	}

	//@Hints({@Hint("hint1"), @Hint("hint2")}
	@Hint("hint1")
	@Hint("hint2")
	class Person {
	}

	@Test
	public void testRepeatAnno() {
		Hint hint = Person.class.getAnnotation(Hint.class);
		System.out.println(hint); // null
		Hints hints1 = Person.class.getAnnotation(Hints.class);
		System.out.println(hints1.value().length); // 2
		Hint[] hints2 = Person.class.getAnnotationsByType(Hint.class);
		System.out.println(hints2.length);
	}
}
